<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<style>
    .layui-table-header{
        height: 72px !important;
        border-top: 1px solid #d1d1d1;
    }
    .layui-table-fixed-r .layui-table-header .layui-table-cell {
        height: 70px !important;
        line-height: 70px !important;
    }
</style>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">证书分类</label>
                        <div class="layui-input-block">
                            <select class="layui-select" id="cert_type"></select>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">证书名称</label>
                        <div class="layui-input-block">
                            <input type="text" id="cert_name" name="cert_name" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">证书专业</label>
                        <div class="layui-input-block">
                            <input type="text" id="cert_major" name="cert_major" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <input type="hidden" id="type" name="type" value="">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" style="margin-bottom: 20px;">
                <div class="layui-card">
                    <div class="layui-card-body">
                        <table class="layui-table">
                            <tbody>
                            <tr>
                                <td colspan="4" style="font-size: 14px;"><b>企业主要人员状况：</b></td>
                            </tr>
                            <tr>
                                <td style="font-size: 14px;"><b><a style="cursor: pointer;" onclick="jump_cert('建造师')">建造师总数(<span id="jzs_all"></span>)</a></b></td>
                                <td><a style="cursor: pointer;" onclick="jump_cert('一级建造师')">一级建造师(<span id="jzs_yiji"></span>)</a></td>
                                <td><a style="cursor: pointer;" onclick="jump_cert('二级建造师')">二级建造师(<span id="jzs_erji"></span>)</a></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td colspan="4" style="font-size: 14px"><b>现场管理人员总数(<span id="xcgl_all"></span>)</b></td>
                            </tr>
                            <tr>
                                <td><a style="cursor: pointer;" onclick="jump_cert('施工员')">施工员(<span id="xcgl_shiyong"></span>)</a></td>
                                <td><a style="cursor: pointer;" onclick="jump_cert('安全员')">安全员(<span id="xcgl_anquan"></span>)</a></td>
                                <td><a style="cursor: pointer;" onclick="jump_cert('造价员')">造价员(<span id="xcgl_zaojia"></span>)</a></td>
                                <td><a style="cursor: pointer;" onclick="jump_cert('质量员')">质量员(<span id="xcgl_zhiliang"></span>)</a></td>
                            </tr>
                            <tr>
                                <td><a style="cursor: pointer;" onclick="jump_cert('劳务员')">劳务员(<span id="xcgl_laowu"></span>)</a></td>
                                <td><a style="cursor: pointer;" onclick="jump_cert('测量员')">测量员(<span id="xcgl_celiang"></span>)</a></td>
                                <td><a style="cursor: pointer;" onclick="jump_cert('机械员')">机械员(<span id="xcgl_jixie"></span>)</a></td>
                                <td><a style="cursor: pointer;" onclick="jump_cert('试验员')">试验员(<span id="xcgl_shiya"></span>)</a></td>
                            </tr>
                            <tr>
                                <td><a style="cursor: pointer;" onclick="jump_cert('资料员')">资料员(<span id="xcgl_ziliao"></span>)</a></td>
                                <td><a style="cursor: pointer;" onclick="jump_cert('标准员')">标准员(<span id="xcgl_biaozhun"></span>)</a></td>
                                <td><a style="cursor: pointer;" onclick="jump_cert('材料员')">材料员(<span id="xcgl_cailiao"></span>)</a></td>
                                <td><a style="cursor: pointer;" onclick="jump_cert('预算员')">监理员(<span id="xcgl_yusuan"></span>)</a></td>
                            </tr>
                            <tr>
                                <td colspan="4" style="font-size: 14px"><b>三类人员总数(<span id="san_all"></span>)</b></td>
                            </tr>
                            <tr>
                                <td><a style="cursor: pointer;" onclick="jump_cert('建安A证')">建安A证(<span id="san_jiana"></span>)</a></td>
                                <td><a style="cursor: pointer;" onclick="jump_cert('建安B证')">建安B证(<span id="san_jianb"></span>)</a></td>
                                <td><a style="cursor: pointer;" onclick="jump_cert('建安C证')">建安C证(<span id="san_jianc"></span>)</a></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td><a style="cursor: pointer;" onclick="jump_cert('水安A')">水安A(<span id="san_shuia"></span>)</a></td>
                                <td><a style="cursor: pointer;" onclick="jump_cert('水安B')">水安B(<span id="san_shuib"></span>)</a></td>
                                <td><a style="cursor: pointer;" onclick="jump_cert('水安C')">水安C(<span id="san_shuic"></span>)</a></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td colspan="2" style="font-size: 14px;"><b><a style="cursor: pointer;" onclick="jump_cert('技术工人')">技术工人总数(<span id="js_all"></span>)</a></b></td>
                                <td colspan="2" style="cursor: pointer;"><a style="cursor: pointer;" onclick="jump_cert('中级工')">中级工及以上(<span id="js_gao_all"></span>)</a></td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <!-- <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.LAY_TABLE_INDEX}}')">查看</a> -->
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>
    function jump_cert(cert_name) {
        open_page('../cert/index.php?cert_name='+encodeURI(cert_name),'证书','100%','100%');
    }

    var currButAuth, currTabData, queryStatus = 0;
    var cols = []; var person_nature = [];
    layui.use(['table','form','soulTable'], function () {
        var table = layui.table, form = layui.form, soulTable = layui.soulTable;

        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        facade.ajax({type: 'get', url: ask_cert_form_list, async: false}).done(function(res){
            if (res.code === 2000) {
                cols = res.data;
            }
        });

        setSouTableExport('编制');
        table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_cert_form_list),where: {}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response
            ,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text
            ,parseData: function (res) {
                currButAuth = res.data.butauth;
                tableButShow(currButAuth);

                if(queryStatus === 0){
                    var cert_typeArr = res.data.cert_type;
                    var cert_type_str = '';
                    for(var i=0; i<cert_typeArr.length; i++){
                        cert_type_str += '<option value="'+cert_typeArr[i].value+'">'+cert_typeArr[i].name+'</option>';
                    }
                    $('#cert_type').html(cert_type_str);

                    person_nature = res.data.person_nature;

                    queryStatus = 1;
                }

                var count = res.data.count_arr;
                $('#jzs_all').text(count.jzs_all);
                $('#jzs_yiji').text(count.jzs_yiji);
                $('#jzs_erji').text(count.jzs_erji);
                $('#xcgl_all').text(count.xcgl_all);
                $('#xcgl_shiyong').text(count.xcgl_shiyong);
                $('#xcgl_anquan').text(count.xcgl_anquan);
                $('#xcgl_zaojia').text(count.xcgl_zaojia);
                $('#xcgl_zhiliang').text(count.xcgl_zhiliang);
                $('#xcgl_laowu').text(count.xcgl_laowu);
                $('#xcgl_celiang').text(count.xcgl_celiang);
                $('#xcgl_jixie').text(count.xcgl_jixie);
                $('#xcgl_shiya').text(count.xcgl_shiya);
                $('#xcgl_ziliao').text(count.xcgl_ziliao);
                $('#xcgl_biaozhun').text(count.xcgl_biaozhun);
                $('#xcgl_cailiao').text(count.xcgl_cailiao);
                $('#xcgl_yusuan').text(count.xcgl_yusuan);
                $('#js_all').text(count.js_all);
                $('#js_gao_all').text(count.js_gao_all);
                $('#san_jiana').text(count.san_jiana);
                $('#san_jianb').text(count.san_jianb);
                $('#san_jianc').text(count.san_jianc);
                $('#san_shuia').text(count.san_shuia);
                $('#san_shuib').text(count.san_shuib);
                $('#san_shuic').text(count.san_shuic);
                $('#san_all').text(count.san_all);

                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [cols[0],cols[1]]
            , done: function (res) {
                soulTable.render(this);

                currTabData = res.data;
                $.each(currTabData, function(index,item){
                    var chk = $('tr[data-index=' + item.LAY_TABLE_INDEX + '] .tab-list-authbut');
                    for (var key in currButAuth) {
                        if(currButAuth[key].pagetype === 0 || currButAuth[key].pagetype === 1){
                            chk.append(' <a ' +
                                'href="javascript:;" ' +
                                'class="bar_opt layui-hide" ' +
                                'lay-event="search" ' +
                                'data-butname="'+currButAuth[key].butname+'" ' +
                                'data-title="'+currButAuth[key].title+'" ' +
                                'onclick="auth_but_func_'+currButAuth[key].butname+'(\''+currButAuth[key].title+'\', '+index+')"' +
                                '>'+currButAuth[key].title+'' +
                                '</a>');
                        }
                    }
                });
                show_tab_but(currTabData);
            }
        });


        listTableSearch(form, table);


        table.on('tool(datalist)', function(obj){
            var data = obj.data;
            person_nature.forEach(function (item) {
                if(obj.event === 'num'+item.value){
                    open_page('../cert/index.php?cert_type='+data.cert_type+'&cert_name='+encodeURI(data.cert_name)+'&cert_major='+encodeURI(data.cert_major)+'&person_nature='+item.value,'证书','100%','100%');
                }
            });
            if(obj.event === 'all_num'){
                open_page('../cert/index.php?cert_type='+data.cert_type+'&cert_name='+encodeURI(data.cert_name)+'&cert_major='+encodeURI(data.cert_major),'证书','100%','100%');
            }
        });
    });


    function auth_but_func_add(buttitle, index){
        var trData = currTabData[index];
        openPageEdit('add.php?close=1');
    }
    function auth_but_func_edit(buttitle, index){
        var trData = currTabData[index];
        openPageEdit('edit.php?close=1&id='+trData.id);
    }
    function auth_but_func_delete(buttitle, index){
        var trData = currTabData[index];
        data_delete(ask_cert_form_del, {id:trData.id});
    }
</script>
</body>
</html>
